<%@page import="javabean.JDBCBean"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="javabean.Admin"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>bookedit</title>
  <!-- layui -->
  <link rel="stylesheet" href="../public/layui/css/layui.css">
  <script src="../public/layui/layui.js"></script>
 
  <style>
    .layui-form{
      margin: 10px 20px;
    }
  </style>
</head>
<body>
  
  <%
  	JDBCBean db = new JDBCBean();
  	String id = request.getParameter("id");
	ResultSet resultSet = null;
	ResultSet librarySet = null;
	ResultSet bookSortSet = null;
	String sql = "select * from postman where Pid= '" +id +"'";
 	resultSet =  db.executeQuery(sql);
 	resultSet.next();
  	String name = resultSet.getString("Pname");
  	String areaid = resultSet.getString("areaid");
  	String pphonenumber = resultSet.getString("Pphonenumber");

  	db.close();
  	// 获取图书馆列表
//  	JDBCBean db2 = new JDBCBean();
//  	String librarySql = "select * from library";
//  	librarySet = db2.executeQuery( librarySql );
  	
  	
  	// 获取书籍分类
//  	JDBCBean db3 = new JDBCBean();
//  	String bookSortSql = "select * from book_sort";
//  	bookSortSet = db3.executeQuery( bookSortSql );
  	
  %>
  
  <form class="layui-form   layui-form-pane" action="">
 <%-- 隐藏id --%>
  <input type="id" name="id" value=<%=id %> class="layui-hide">
  <!-- 书名 -->
  <div class="layui-form-item">
    <label class="layui-form-label">快递员姓名</label>
    <div class="layui-input-block">
      <input type="text" name="name" value=<%=name %> required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
    </div>
  </div>
  <!-- 作者 -->
<%--  <div class="layui-form-item">--%>
<%--    <label class="layui-form-label">管辖地区</label>--%>
<%--    <div class="layui-input-block">--%>
<%--        <select name="area" lay-verify="required">--%>
<%--            <option value=""></option>--%>
<%--            <option value="a" >a</option>--%>
<%--            <option value= "b" >b</option>--%>
<%--            <option value="c" >c</option>--%>
<%--            <option value="d" >d</option>--%>
<%--        </select>--%>
<%--    </div>--%>
<%--  </div>--%>
  <div class="layui-form-item">
      <label class="layui-form-label">快递员联系方式</label>
      <div class="layui-input-block">
             <input type="text" name="phonenumber" value=<%=pphonenumber %> required  lay-verify="required" placeholder="请输入联系方式" autocomplete="off" class="layui-input">
      </div>
  </div>
  <!-- 图书馆 -->
<%--  <div class="layui-form-item">--%>
<%--    <label class="layui-form-label">图书馆</label>--%>
<%--    <div class="layui-input-block">--%>
<%--      <select name="library_id" lay-verify="required">--%>
<%--      	<option value=""></option>--%>
<%--      	<% while( librarySet.next() ){ %>--%>
<%--      		&lt;%&ndash; 选中原来的 图书馆&ndash;%&gt;--%>
<%--        	<option value=<%=librarySet.getString("id") %> <%if(Integer.parseInt(librarySet.getString("id")) == library_id){ out.print("selected"); } %> ><%=librarySet.getString("name") %></option>--%>
<%--        <%} %>--%>
<%--      </select>--%>
<%--    </div>--%>
<%--  </div>--%>


   

  
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
    </div>
  </div>
</form>
<script>

layui.use(['form', 'layedit', 'jquery'], function(){
  //layer.closeAll();
  $ = layui.jquery;
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit;
  /**
   * 因为富文本存在xss注入，以下代码不用了，如果需要可以开启
   */
  /* 
  var editIndex = layedit.build('LAY_demo_editor');
  // 自定义验证规则
  form.verify({
	  // 解决异步传输问题
	  content: function(value){
		  return layedit.sync(editIndex);
	  }
  }) 
  */
  //监听提交
  form.on('submit(formDemo)', function(data){
    $.ajax({
    	url: './postmanEdit',
    	method: 'post',
    	data: data.field, //JSON.stringify(data.field),
    	dataType: 'json',
    	success: function(data){
    		if(data.code == "0"){
    			parent.layer.msg("修改成功",{
    				icon: 6,
    				time: 500
    			});
    			setTimeout(function(){
    				var index = parent.layer.getFrameIndex(window.name); //操作父页面
            		parent.layer.close(index);
    			}, 500);
        		
    		}else{
    			layer.msg("修改失败");
    		}
    	    
    	}
    })
    
    
    return false;
  });
});

</script>
<%
	// 关闭资源

%>
</body>
</html>